import { Map } from 'immutable' 
import * as actionTypes from './constants';

//转换成 immutable  为了性能优化浅层比较
const defaultState = Map({
  topBanners: [],
  hotRecommends: [],
  newAlbums: [],
  // topLists: []
  settleSings: []
})

function reducer(state = defaultState, action) {
  switch (action.type) {
    case actionTypes.CHANGE_TOP_BANNERS:
      // return {...state, topBanners: action.topBanners} 传统方法
      return state.set('topBanners', action.topBanners) //用immutable 可以提高性能
    case actionTypes.CHANGE_HOT_RECOMMEND:
      return state.set('hotRecommends', action.hotRecommends)
    case actionTypes.CHANGE_NEW_ALBUM:
      return state.set('newAlbums', action.newAlbums)
    // case actionTypes.CHANGE_UP_RANKING:
    //   return state.set('topLists', action.TopLists)
    case actionTypes.CHANGE_SETTLE_SONGER:
      return state.set("settleSings", action.settleSings)
    default:  
    return state;
  }
}

export default reducer;










// import { Map } from 'immutable';

// import * as actionTypes from './constants';

// const defaultState = Map({
//   topBanners: [],
//   hotRecommends: [],
//   newAlbums: [],

//   upRanking: {},
//   newRanking: {},
//   originRanking: {},
// });

// function reducer(state = defaultState, action) {
//   switch (action.type) {
//     case actionTypes.CHANGE_TOP_BANNERS:
//       return state.set("topBanners", action.topBanners);
//     case actionTypes.CHANGE_HOT_RECOMMEND:
//       return state.set("hotRecommends", action.hotRecommends);
//     case actionTypes.CHANGE_NEW_ALBUM:
//       return state.set("newAlbums", action.newAlbums);
      
//     case actionTypes.CHANGE_UP_RANKING:
//       return state.set("upRanking", action.upRanking);
//     case actionTypes.CHANGE_NEW_RANKING:
//       return state.set("newRanking", action.newRanking);
//     case actionTypes.CHANGE_ORIGIN_RANKING:
//       return state.set("originRanking", action.originRanking);
//     default:
//       return state;
//   }
// }

// export default reducer;
